let newVue = {
  viewer: null
}
// newVue.viewer = this

/**
 * Created by yan on 2018-4-10.
 */
function sum(r, r1) {
  var sum = 0.0;
  for (var i = 0; i < r.length; i++) {
    sum += r[i] * r1[i];
  }
  return sum;
}
function vecProd(a, b) {
  let c = [];
  c[0] = a[1] * b[2] - a[2] * b[1];
  c[1] = a[2] * b[0] - a[0] * b[2];
  c[2] = a[0] * b[1] - a[1] * b[0];
  return c;
}
/**
 *  offsetToLongLat根据偏移量计算目标点经纬度
 * @param {} ecltPos  p0圆心点坐标数组
 * @param {} stltPos  p1顶点坐标数组
 * @param {} r0       圆心半径
 * @param {} N        取点数
 */
function calclp(ecltPos, stltPos, r0, N) {
  var p0 = [ecltPos[0] * Math.PI / 180, ecltPos[1] * Math.PI / 180, ecltPos[2]];
  var p1 = [stltPos[0] * Math.PI / 180, stltPos[1] * Math.PI / 180, stltPos[2]];
  var r0 = r0;
  var N = N;
  var HB = [0, 0, 0];
  var LB = [0, 0, 0];
  var BB = [0, 0, 0];
  var re = 6371007;
  var rad = 57.2957795130823209;
  var r1 = [0, 0, 0];
  var r2 = [0, 0, 0];
  var dr = [0, 0, 0];
  var r = [0, 0, 0];
  var rc = [0, 0, 0];
  var TM = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
  var rh, d, dA, a;
  if (N < 2) {
    return null;
  }
  rh = re + p0[2];
  r1[0] = rh * Math.cos(p0[1]);
  r1[1] = r1[0] * Math.sin(p0[0]);
  r1[2] = rh * Math.sin(p0[1]);
  r1[0] = r1[0] * Math.cos(p0[0]);
  rh = re + p1[2];
  r2[0] = rh * Math.cos(p1[1]);
  r2[1] = r2[0] * Math.sin(p1[0]);
  r2[2] = rh * Math.sin(p1[1]);
  r2[0] = r2[0] * Math.cos(p1[0]);
  for (var i = 0; i < dr.length; i++) {
    dr[i] = r2[i] - r1[i];
  }
  d = Math.sqrt(sum(dr, dr));

  var teTM = [];
  TM[0][2] = dr[0] / d;
  TM[1][2] = dr[1] / d;
  TM[2][2] = dr[2] / d;
  teTM[0] = TM[0][2];
  teTM[1] = TM[1][2];
  teTM[2] = TM[2][2];

  var tempr1 = [0, 0, 0];
  for (var i = 0; i < r1.length; i++) {
    tempr1[i] = -r1[i];
  }
  var temp = vecProd(tempr1, teTM);
  var xx = Math.sqrt(sum(temp, temp));
  TM[0][0] = temp[0];
  TM[1][0] = temp[1];
  TM[2][0] = temp[2];
  for (var i = 0; i < TM.length;
       i++
  ) {
    TM[i][0] = TM[i][0] / xx;
  }

  var TM2 = [0, 0, 0];
  for (var i = 0; i < TM.length; i++) {
    TM2[i] = TM[i][2];
  }
  var TM0 = [0.0, 0.0, 0.0];
  for (var i = 0; i < TM.length; i++) {
    TM0[i] = TM[i][0];
  }
  var TM1 = vecProd(TM2, TM0);
  for (var i = 0; i < TM.length; i++) {
    TM[i][1] = TM1[i];
  }
  dA = 2 * Math.PI / (N - 1);
  a = 0;
  r[2] = 0;
  for (var i = 0; i < N; i++) {
    r[0] = r0 * Math.cos(a);
    r[1] = r0 * Math.sin(a);
    rc[0] = TM[0][0] * r[0] + TM[0][1] * r[1] + TM[0][2] * r[2] + r1[0];
    rc[1] = TM[1][0] * r[0] + TM[1][1] * r[1] + TM[1][2] * r[2] + r1[1];
    rc[2] = TM[2][0] * r[0] + TM[2][1] * r[1] + TM[2][2] * r[2] + r1[2];
    HB[i] = Math.sqrt(sum(rc, rc));
    LB[i] = Math.atan2(rc[1], rc[0]) * rad;
    BB[i] = Math.asin(rc[2] / HB[i]) * rad;
    HB[i] = HB[i] - re;
    a = a + dA;
  }
  var list = [];
  for (var i = 0; i < HB.length; i++) {
    list.push(LB[i]);
    list.push(BB[i]);
    list.push(HB[i]);
  }

  return list;
}
let container = {};//声明一个容器存储数据 覆盖屏增删改共用

/**
 *  addModel 添加模型
 * @param {} modelId     模型ID
 * @param {} modelName   模型名称
 * @param {} modelSrc    模型路径
 * @param {} lon         模型经度
 * @param {} lat         模型纬度
 * @param {} height      模型高度
 * @param {} headingP    模型偏航角
 * @param {} pitchP      模型俯仰角
 * @param {} rollP       模型滚动角
 * @param {} modelShow   模型显隐
 * @param {} description 描述信息
 */
// 添加模型
let addModel = (lon, lat, height, headingP, pitchP, rollP, modelId, modelName, modelSrc, minSize, maxSize, lableText) => {

  let position = newVue.viewer.Cesium.Cartesian3.fromDegrees(lon, lat, height)
  let heading = newVue.viewer.Cesium.Math.toRadians(headingP)
  let pitch = newVue.viewer.Cesium.Math.toRadians(pitchP)
  let roll = rollP
  let hpr = new newVue.viewer.Cesium.HeadingPitchRoll(heading, pitch, roll)
  let orientation = newVue.viewer.Cesium.Transforms.headingPitchRollQuaternion(position, hpr)
  let entity = newVue.viewer.viewer.entities.add({
    id: modelId,
    name: modelName,
    show: true,
    position: position,
    orientation: orientation,
    model: {
      // scale: scale,
      uri: modelSrc,
      minimumPixelSize: minSize,
      maximumScale: maxSize,
      // runAnimations: true,
      // clampAnimations: true
    },
    label: {
      text: lableText,
      font: "12pt Source Han Sans CN",
      fillColor: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString("#ffffff"), .5)
    }
  })
  // newVue.viewer.viewer.trackedEntity = entity;
  return entity
}


/**
 *  添加链路
 *  @param  data: [90,0,2500000,140,0,2500000]   两个实体间的经纬度高度数据
 *  @param  wid: 宽度
 *  */
function addLink(id, name, data, wid, colour, alpha) {
  function PolylineTrailLinkMaterialProperty(color, duration) {
    this._definitionChanged = new newVue.viewer.Cesium.Event();
    this._color = undefined;
    this._colorSubscription = undefined;
    this.color = color;
    this.duration = duration;
    this._time = (new Date()).getTime();
  }

  newVue.viewer.Cesium.defineProperties(PolylineTrailLinkMaterialProperty.prototype, {
    isConstant: {
      get: function () {
        return false;
      }
    },
    definitionChanged: {
      get: function () {
        return this._definitionChanged;
      }
    },
    color: newVue.viewer.Cesium.createPropertyDescriptor("color")
  });
  PolylineTrailLinkMaterialProperty.prototype.getType = function (time) {
    return "PolylineTrailLink";
  };
  PolylineTrailLinkMaterialProperty.prototype.getValue = function (time, result) {
    if (!newVue.viewer.Cesium.defined(result)) {
      result = {};
    }
    result.color = newVue.viewer.Cesium.Property.getValueOrClonedDefault(
      this._color,
      time,
      newVue.viewer.Cesium.Color.WHITE,
      result.color
    );
    result.image = newVue.viewer.Cesium.Material.PolylineTrailLinkImage;
    result.time = ((new Date().getTime() - this._time) % this.duration) / this.duration;
    return result;
  };
  PolylineTrailLinkMaterialProperty.prototype.equals = function (other) {
    return this === other || (other instanceof PolylineTrailLinkMaterialProperty && Property.equals(this._color, other._color))
  };
  newVue.viewer.Cesium.PolylineTrailLinkMaterialProperty = PolylineTrailLinkMaterialProperty;
  newVue.viewer.Cesium.Material.PolylineTrailLinkType = "PolylineTrailLink";
  newVue.viewer.Cesium.Material.PolylineTrailLinkImage = "../../static/model/images/dataTransmission.png";
  newVue.viewer.Cesium.Material.PolylineTrailLinkSource = `czm_material czm_getMaterial(czm_materialInput materialInput){
                                                            czm_material material = czm_getDefaultMaterial(materialInput);
                                                            vec2 st = materialInput.st;
                                                            vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));
                                                            material.alpha = colorImage.a * color.a;
                                                            material.diffuse = (colorImage.rgb+color.rgb)/5.0;
                                                            return material;
                                                          }`;
  newVue.viewer.Cesium.Material._materialCache.addMaterial(newVue.viewer.Cesium.Material.PolylineTrailLinkType, {
    fabric: {
      type: newVue.viewer.Cesium.Material.PolylineTrailLinkType,
      uniforms: {
        image: newVue.viewer.Cesium.Material.PolylineTrailLinkImage,
        color: new newVue.viewer.Cesium.Color(1.0, 0.0, 0.0, 0.5),
        time: 0
      },
      source: newVue.viewer.Cesium.Material.PolylineTrailLinkSource
    },
    translucent: function (material) {
      return true;
    }
  });
  console.log(id)
  let line=newVue.viewer.viewer.entities.add({
    id, name,
    polyline: {
      positions: newVue.viewer.Cesium.Cartesian3.fromDegreesArrayHeights([...data]),
      width: wid,
      // clampToGround: true,   // 贴地
      //  material: new Cesium.PolylineTrailLinkMaterialProperty(Cesium.Color.WHITE, 1000)
      material: new newVue.viewer.Cesium.PolylineTrailLinkMaterialProperty(newVue.viewer.Cesium.Color.RED,1000),
      arcType: newVue.viewer.Cesium.ArcType.NONE,
    }
  });
  return line;
}

/**
 *  updateModel 更新模型
 * @param {} modelId     模型ID
 * @param {} lon         模型经度
 * @param {} lat         模型纬度
 * @param {} height      模型高度
 * @param {} heading     模型偏航角
 * @param {} pitch       模型俯仰角
 * @param {} roll        模型滚动角
 * @param {} description 描述信息
 */
function updateModel(modelId, lon, lat, height, heading, pitch, roll, description) {
  let position = newVue.viewer.Cesium.Cartesian3.fromDegrees(lon, lat, height)//设置位置
  let headingP = newVue.viewer.Cesium.Math.toRadians(heading);//设置偏航角
  let pitchP = newVue.viewer.Cesium.Math.toRadians(pitch);//设置俯仰角
  let rollP = roll;//设置滚动角
  let hpr = new newVue.viewer.Cesium.HeadingPitchRoll(headingP, pitchP, rollP);//生成四元数
  let orientation = newVue.viewer.Cesium.Transforms.headingPitchRollQuaternion(position, hpr);//设置姿态
//添加模型
  let id = newVue.viewer.viewer.entities.getById(1)
  //console.log(id);
  //console.log(modelId, lon, lat, height);
  id.position = position
  id.orientation = orientation
}

/**
 * 创建轨迹 creatLine("aa","aa",[-75, 39, 250000,-125, 39, 250000],red,0.5)
 * polylineArr 轨迹数据
 * */
// 创建卫星轨迹
let creatLine = (id, name, polylineArr, color, alph) =>{
  let line = newVue.viewer.viewer.entities.add({
      id:id + "line",
      show: true,
      name :name,
      polyline : {
        positions : newVue.viewer.Cesium.Cartesian3.fromDegreesArrayHeights(polylineArr),
        width : 2,
        material : newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alph)
      }
    });
    return line;
  //console.log(newVue.viewer)
}

/**
 * 创建圆锥波束  coneLight("1111",[80.23, 39.9, 0],[80.23, 32.9, 6000000],20000,20,"red",.5)

 * ecltPos 圆心点坐标
 * stltPos 顶点坐标
 * range  探测距离
 * num    取点数
 * */
// 创建圆锥波束
let coneLight = (tempId, stltPos, ecltPos, range, num, color, alph) => {
  let points = calclp(ecltPos, stltPos, range, num)
  console.log(points, '===================')
  for (let i = 0; i < points.length; i += 3) {
    let array = [
      stltPos[0], stltPos[1], stltPos[2], points[i], points[i + 1], points[i + 2]
    ];
    if (i + 3 == points.length) {
      array.push(points[0]);
      array.push(points[1]);
      array.push(points[2]);
    } else {
      array.push(points[i + 3]);
      array.push(points[i + 4]);
      array.push(points[i + 5]);
    }
    container[tempId+i] = array // 将每次的数据存入容器
    console.log(container,"-=-=-=-=-=-=-=-==-==-=-==-=-=-")
    newVue.viewer.viewer.entities.add({
      id: tempId + i,
      polygon: {
        hierarchy: new newVue.viewer.Cesium.CallbackProperty(function () {
          return newVue.viewer.Cesium.Cartesian3.fromDegreesArrayHeights(container[tempId+ i]);
        }, false),
        //hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(array),
        perPositionHeight: true,
        outline: false,
        outlineColor: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alph),
        material: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alph)
      }
    });
  }
}

/**
  * 创建圆锥覆盖范围  coverage(110, 0 ,0, "3", "cover")
  * */
// 创建圆锥覆盖范围
let coverage = (lon, lat, height, modelId, modelName, color, alpha) => {
  let position = newVue.viewer.Cesium.Cartesian3.fromDegrees(lon, lat, height)
  let entity = newVue.viewer.viewer.entities.add({
    id: modelId + "cover",
    name: modelName,
    show: true,
    position: position,
    cylinder: {
      HeightReference: newVue.viewer.Cesium.HeightReference.CLAMP_TO_GROUND,
      length: 5000000,
      topRadius: 0,
      bottomRadius: 1500000,
      material: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alpha),
      outline: true,
      bottomSurface: false,
      numberOfVerticalLines: 0,
      outlineColor: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alpha),
    }
  })
  return entity
}

/**
 * 新版经纬度线
 *  @param {} entitiesId 覆盖屏的id(新创建的雷达id)
 *  @param {} stpLon  设备经度
 *  @param {} stplat  设备纬度
 *  @param {} stpAlt  设备高度 米
 *  @param {} range   雷达探测距离 千米
 *  @param {} color   覆盖屏颜色 0.5,0.5,0.5,0.3 cesium的rgba和CSS的rgba不一致  css的rgba/255为cesium的rgba值
 * */
let createGrid = (entitiesId, stpLon, stplat, stpAlt, Range, color) => {
  let position = newVue.viewer.Cesium.Cartesian3.fromDegrees(stpLon, stplat, stpAlt);
  let modelMatrix = newVue.viewer.Cesium.Transforms.eastNorthUpToFixedFrame(position);
  let azSpan = 5;
  let elSpan = 5;
  let rad = Math.PI / 180;
  let polylines = new newVue.viewer.Cesium.PolylineCollection();
  let lineWidth = 1;
  let lineColor = new newVue.viewer.Cesium.Color(color[0], color[1], color[2], color[3]);
  // 画纬度线
  for (let el = 0; el < 90; el += elSpan) {
    let sinEl = Math.sin(el * rad);
    let cosEl = Math.cos(el * rad);
    let z = Range * sinEl;
    let latLine = []
    for (let az = 0; az <= 360; az += azSpan) {
      let x = Range * cosEl * Math.sin(az * rad);
      let y = Range * cosEl * Math.cos(az * rad);
      latLine.push(new newVue.viewer.Cesium.Cartesian3(x, y, z));
    }
    let p = polylines.add({
      positions: latLine,
      width: lineWidth
    });
    p.material = newVue.viewer.Cesium.Material.fromType('Color');
    p.material.uniforms.color = lineColor;
  }
  // 画经度线
  for (let az = 0; az < 360; az += azSpan) {
    let sinAz = Math.sin(az * rad);
    let cosAz = Math.cos(az * rad);
    let lngLine = [];
    for (let el = 0; el <= 90; el += elSpan) {
      let cosEl = Math.cos(el * rad);
      let sinEl = Math.sin(el * rad);
      let x = Range * cosEl * sinAz;
      let y = Range * cosEl * cosAz;
      let z = Range * sinEl;
      lngLine.push(new newVue.viewer.Cesium.Cartesian3(x, y, z));
    }
    let p = polylines.add({
      positions: lngLine,
      width: lineWidth
    });
    p.material = newVue.viewer.Cesium.Material.fromType('Color');
    p.material.uniforms.color = lineColor;
  }
  polylines.modelMatrix = modelMatrix;
  polylines.id = entitiesId + "grid";
  newVue.viewer.viewer.scene.primitives.add(polylines);
  return polylines;
}

/**
 * 移动卫星光束效果         moveLight("sata1", [0, 0, 36000000], [0, 0,3000000], nsPointArr)
 * @param {} entitiesId 目标id
 * @param {} stltPos 卫星三维坐标数组
 * @param {} targetPoint 目标点三维坐标数据
 * @param {} pointArrContent 目标点数组容器 为固定值 var pointArrContent={}
 */
let moveLight = (entitiesId, stltPos, targetPoint, pointArrContent) => {
  clearInterval(pointArrContent[entitiesId])
  let points = [targetPoint[0] + 2.5, targetPoint[1] + 2.5, targetPoint[2],
    targetPoint[0] - 2.5, targetPoint[1] + 2.5, targetPoint[2],
    targetPoint[0] - 2.5, targetPoint[1] - 2.5, targetPoint[2],
    targetPoint[0] + 2.5, targetPoint[1] - 2.5, targetPoint[2]]
  for (let i = 0; i < points.length; i += 3) {
    let array = [
      stltPos[0], stltPos[1], stltPos[2], points[i], points[i + 1], points[i + 2]
    ];
    if (i + 3 == points.length) {
      array.push(points[0]);
      array.push(points[1]);
      array.push(points[2]);
    }
    else {
      array.push(points[i + 3]);
      array.push(points[i + 4]);
      array.push(points[i + 5]);
    }
    pointArrContent[entitiesId + i] = array
  }
}

/**
 * 预警卫星扫描效果     linearScan('sate' + data.equipmentID, [lonS,latS,h,leftLon,leftLat,leftAlt,righttLon,rightLat,rightAlt], "#4e88e4", .5)
 * @param {} entitiesId 目标id
 * @param {} stltPos 宽幅相机扫描光束坐标点
 * @param {} color CSS颜色代码，例如#FF0000
 * @param {} alpha 透明度 0.5用.5表示
 */
let linearScan = (entitiesId, stltPos, color, alpha) => {
  if (newVue.viewer.viewer.entities.getById('sate'+entitiesId)) {
    newVue.viewer.viewer.entities.getById('sate'+entitiesId).polygon.hierarchy = new newVue.viewer.Cesium.CallbackProperty(function () {
      return newVue.viewer.Cesium.Cartesian3.fromDegreesArrayHeights(stltPos);
    }, false)
  } else {
    newVue.viewer.viewer.entities.add({
      id: entitiesId + "cover",
      polygon: {
        hierarchy: new newVue.viewer.Cesium.CallbackProperty(function () {
          return newVue.viewer.Cesium.Cartesian3.fromDegreesArrayHeights(stltPos);
        }, false),
        material: newVue.viewer.Cesium.Color.fromAlpha(newVue.viewer.Cesium.Color.fromCssColorString(color), alpha),
        perPositionHeight: true,
      }
    });
  }
}

/**
 * 预警卫星扫描区域    lineScanContent([0,0,36000000])
 * @param {} entitiesId 目标id
 * @param {} stltPos 卫星三维坐标数组
 */
let lineScanContent = (stltPos) => {
  let temp = -90;
  let tempArrContent = [];
  for (var i = -90; i < 91; i++) {
    temp++
    tempArrContent.push(stltPos[0] - 60, temp, 0)
    if (temp == 90) {
      for (var k = 90; k > -90; k--) {
        temp--
        tempArrContent.push(stltPos[0] + 60, temp, 0)
      }
    }
  }
  console.log(tempArrContent);
  return tempArrContent;
}

/**
 * 卫星凝视相机扫描光束
 * 调用方法 var nsPointArr={};    lightShinePolygon('scanSate' + data.equipmentID, [data.lonS, data.latS, data.h], [data.lonS, data.latS, 0], "#47bfca", .8, nsPointArr)
 * @param {} entitiesId 目标id
 * @param {} stltPos 卫星三维坐标数组
 * @param {} targetPoint 目标点三维坐标数据
 * @param {} color CSS颜色代码，例如#FF0000
 * @param {} pointArrContent 目标点数组容器 为固定值 var pointArrContent={}
 */
let lightShinePolygon = (entitiesId, stltPos, targetPoint, color, alph, pointArrContent) => {
  var flag = 0,
    points = []
  console.log(entitiesId);
  console.log(stltPos);
  console.log(targetPoint);
  console.log(pointArrContent);
  function light() {
    if (flag == 1) {
      points = [targetPoint[0], targetPoint[1] + 2.5, targetPoint[2],
        targetPoint[0] + 5, targetPoint[1] + 2.5, targetPoint[2],
        targetPoint[0] + 5, targetPoint[1] - 2.5, targetPoint[2],
        targetPoint[0], targetPoint[1] - 2.5, targetPoint[2]]
      flag = 0
    } else {
      points = [targetPoint[0], targetPoint[1] + 2.5, targetPoint[2],
        targetPoint[0] - 5, targetPoint[1] + 2.5, targetPoint[2],
        targetPoint[0] - 5, targetPoint[1] - 2.5, targetPoint[2],
        targetPoint[0], targetPoint[1] - 2.5, targetPoint[2]]
      flag = 1
    }
    //console.log(points);
    for (let i = 0; i < points.length; i += 3) {
      let array = [
        stltPos[0], stltPos[1], stltPos[2], points[i], points[i + 1], points[i + 2]
      ];
      if (i + 3 == points.length) {
        array.push(points[0]);
        array.push(points[1]);
        array.push(points[2]);
      }
      else {
        array.push(points[i + 3]);
        array.push(points[i + 4]);
        array.push(points[i + 5]);
      }
      pointArrContent[entitiesId + i] = array
      if (viewer.entities.getById(entitiesId + i)) {
        viewer.entities.getById(entitiesId + i).polygon.hierarchy = new Cesium.CallbackProperty(function () {
          return Cesium.Cartesian3.fromDegreesArrayHeights(pointArrContent[entitiesId + i]);
        }, false)
      } else {
        viewer.entities.add({
          id: entitiesId + i,
          polygon: {
            hierarchy: new Cesium.CallbackProperty(function () {
//                                    return Cesium.Cartesian3.fromDegreesArrayHeights(JSON.parse(sessionStorage.getItem("line" + i + x)));
              return Cesium.Cartesian3.fromDegreesArrayHeights(pointArrContent[entitiesId + i]);
            }, false),
            perPositionHeight: true,
            outline: true,
            outlineColor: Cesium.Color.fromAlpha(Cesium.Color.fromCssColorString(color), alph),
            material: Cesium.Color.fromAlpha(Cesium.Color.fromCssColorString(color), alph)
          }
        });
      }
    }
    //console.log(pointArrContent);
  }
  pointArrContent[entitiesId] = setInterval(light, 200)
}

/**
 * 删除三角形模拟卫星光束    var nsPointArr={};    removeLightShinePolygon('scanSate' + data.equipmentID, [data.lonS, data.latS, data.h], [data.lonS, data.latS, 0], nsPointArr)
 * @param {} entitiesId 目标id
 * @param {} stltPos 卫星三维坐标数组
 * @param {} targetPoint 地面目标点周围四个顶点集合
 * @param {} pointArrContent 目标点数组容器 为固定值 var pointArrContent={}
 */
let removeLightShinePolygon = (entitiesId, stltPos, targetPoint, pointArrContent) => {
  let points = [targetPoint[0] + 2.5, targetPoint[1] + 2.5, targetPoint[2],
    targetPoint[0] - 2.5, targetPoint[1] + 2.5, targetPoint[2],
    targetPoint[0] - 2.5, targetPoint[1] - 2.5, targetPoint[2],
    targetPoint[0] + 2.5, targetPoint[1] - 2.5, targetPoint[2]]
  for (let i = 0; i < points.length; i += 3) {
    let array = [
      stltPos[0], stltPos[1], stltPos[2], points[i], points[i + 1], points[i + 2]
    ];
    if (i + 3 == points.length) {
      array.push(points[0]);
      array.push(points[1]);
      array.push(points[2]);
    }
    else {
      array.push(points[i + 3]);
      array.push(points[i + 4]);
      array.push(points[i + 5]);
    }
    viewer.entities.remove(viewer.entities.getById(entitiesId + i))
    clearInterval(pointArrContent[entitiesId])
  }
}

export  {
  newVue, addModel, creatLine, coverage, createGrid, updateModel, coneLight, addLink
}
